package com.yuteng.video.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.github.pagehelper.IPage;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yuteng.video.entity.Video;
import com.yuteng.video.mapper.VideoMapper;
import com.yuteng.video.service.VideoService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Random;
import java.util.stream.LongStream;


/**
 * 视频网站服务接口实现
 *
 * @author 余腾
 * @description 视频的一些信息
 * @since 2021-10-27 15:41:54
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class VideoServiceImpl extends ServiceImpl<VideoMapper, Video> implements VideoService {
    @Autowired
    private final VideoMapper videoMapper;

    public void add(Video video) {
    videoMapper.insert(video);
    }

    public PageInfo getAll(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Video> videos = videoMapper.selectList(null);
        PageInfo pageInfo=new PageInfo(videos);
        return pageInfo;
    }
    public void deleteVideoById(Long id){
        videoMapper.deleteById(id);
    }
    public void updateVideo(Video video){
        videoMapper.updateById(video);
    }
}